package com.djl.zenithbite.controller.shopping.store;

import com.djl.zenithbite.common.request.StoreAddRequest;
import com.djl.zenithbite.common.request.StoreDetailRequest;
import com.djl.zenithbite.common.response.BaseResponse;
import com.djl.zenithbite.dto.vo.StoreVO;
import com.djl.zenithbite.entity.Store;
import com.djl.zenithbite.service.shopping.store.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/store")
public class StoreController {

    @Autowired
    private StoreService storeService;

    @PostMapping("/detail")
    public BaseResponse<StoreVO> detail(@RequestBody StoreDetailRequest request){
        return storeService.queryById(request.getStoreId());
    }

    @PostMapping("/add")
    public BaseResponse<StoreVO> add(@RequestBody StoreAddRequest request){
        return storeService.addStore(request);
    }

    @PostMapping("/user/list")
    public BaseResponse<List<StoreVO>> userList(){
        return storeService.userList();
    }

    @PostMapping("/update")
    public BaseResponse<StoreVO> update(@RequestBody StoreAddRequest request){
        return storeService.updateStore(request);
    }
}
